<?php

//mysql database address
define('DB_HOST','127.0.0.1');
//mysql database user
define('DB_USER','root');
//database password
define('DB_PASSWD','123456');
//database name
define('DB_NAME','order');

require_once 'mysqli.php';


$db = MySqlii::getInstance();

$sql = "SELECT * FROM orders";
$res = $db->query($sql);

$totle = array();
$totle['price'] = 0;
$totle['old'] = 0;
$totle['no'] = 0;
while($row = $db->fetch_array($res)) {
    //var_dump($row); exit;
    if($row['buyPrice'] == 0) {
        $totle['no'] = $totle['no'] + $row['buyNumber'];
    }
    $totle['price'] = $totle['price'] + $row['buyPrice'];
    $totle['old']  = $totle['old'] + ($row['agentPrice'] * $row['buyNumber']);
}

$totle['no'] = $totle['no'] - 2;

var_dump($totle);


function getA($expressNumber) {
    $str = 'http://www.kuaidi100.com/query?type=zhongtong&postid='. $expressNumber .'&id=1&valicode=&temp=0.9964493427759196';
    $file =json_decode(file_get_contents($str), TRUE);
    return $file['data'][0];
}

/*
$sql =


$file =json_decode(file_get_contents($sql), TRUE);



var_dump($file['data'][0]['context']);
*/